package com.xinyue.center.errorcode;

import org.slf4j.helpers.MessageFormatter;

/**
 * @Author wang guang shuai
 * @Date 2020/11/9 1:11 上午
 * @Desc
 */
public enum EnumErrorCode {
    ACCOUNT_NOT_EXIST(1001, "账号不存在"),
    PASSWORD_ERROR(1002, "密码错误"),
    ;
    private int errorCode;
    private String errorMsg;

    EnumErrorCode(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public Exception newException(String format, Object... args) {
        if (args != null) {
            format = MessageFormatter.arrayFormat(format, args).getMessage();
        }
        String errorMsg = "errorCode:" + this.errorCode + "," + this.errorMsg + "," + format;
        return new GameCenterException(errorMsg);
    }

    public int getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }
}
